package com.林子祺.CAT旅游系统.dao.placemanagement;

import java.sql.*;

public class UpdatePlace {

    public static void update(int place_id,String name, double price, String provience, String city, String address, String detail){
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/travelsys", "root", "@Blink102417");

            String sql = "update place set name = "+"'"+name+"'"+","+"provience = "+"'"+provience+"'"+","+"city = "+"'"+city+"'"+","+"address = "+"'"+address+"'"+","+"price = "+price+","+"detail = "+"'"+detail+"'"+" where id = "+place_id;

            stmt = conn.createStatement();

            stmt.execute(sql);

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            if(rs != null) {
                try {
                    rs.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if(stmt != null) {
                try {
                    stmt.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if(conn != null) {
                try {
                    conn.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
        }
    }

}
